﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XWeb.Core
{
    public class XWebDbContext : DbContext
    {
        public XWebDbContext()
            :base("name=xweb-db")
        {
            Database.SetInitializer<XWebDbContext>(null);
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<Entities.App>().ToTable("xweb_app");
            modelBuilder.Entity<Entities.App>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.Media>().ToTable("xweb_media");
            modelBuilder.Entity<Entities.Media>().HasKey(p => p.Id);

            modelBuilder.Entity<Entities.MediaFolder>().ToTable("xweb_mediafolder");
            modelBuilder.Entity<Entities.MediaFolder>().HasKey(p => p.Id);
        }
    }
}
